package com.abc.service;

import com.abc.entity.Xuesheng;
import com.abc.mapper.XueshengMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class XueshengService {

    @Autowired
    private XueshengMapper xueshengMapper;

    public List<Xuesheng> findAllXuesheng(){
        return xueshengMapper.findAllXuesheng();
    }
    public String addXuesheng(Xuesheng xuesheng){
        Xuesheng xuesheng1 = xueshengMapper.findByXueshengXingming(xuesheng.getXingming());
        if(xuesheng1!=null){
            return "姓名已存在,添加失败";
        }
        int k = xueshengMapper.insertXuesheng(xuesheng);
        if(k>0){
            return "添加成功";
        }else{
            return "添加失败";
        }
    }

}
